package com.coder520.sync_learning.demo;

import java.awt.*;
import java.lang.invoke.MethodHandleInfo;
import java.util.concurrent.TimeUnit;

public class ClassMonitor {
    public static synchronized void method(){
        System.out.println(Thread.currentThread().getName()+"enter to method");
        try{
            TimeUnit.MINUTES.sleep(10);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }


    public static synchronized void mothed2(){
        System.out.println(Thread.currentThread().getName()+"enter to method2");
        try{
            TimeUnit.MINUTES.sleep(10);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }
    
    public static void main(String[] args){
        new Thread(ClassMonitor::method,"t1").start();

        new Thread(ClassMonitor::mothed2,"t2").start();
    }
}
